﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using System.Xml.Serialization;

namespace ReportGen.Model
{
    [XmlType("RowHeight")]
    public class RowHeight
    {
        [XmlAttribute("defaultValue")]
        public int DefaultValue { get; set; }

        [XmlIgnore]
        public string HeightContent { get; set; }

        [XmlText()]
        public XmlNode[] Height {
            get
            {
                var dom = new XmlDocument();
                return new XmlNode[] { dom.CreateCDataSection(this.HeightContent) };
            }
            set
            {
                if (value == null)
                {
                    this.HeightContent = null;
                    return;
                }
                if (value.Length != 1)
                    throw new InvalidOperationException("Invalid array.");
                var content = value[0];
                if (null == content)
                    throw new InvalidOperationException("Node is null.");
                this.HeightContent = content.Value;
            }
        }
    }
}
